package com.lili.math;

/**
 * @Auther: 李 力
 * @Date: 2024/8/23
 * @Description: 整数反转
 * @version: 1.0
 */
public class LeetCode7 {
    public static int reverse(int x) {
        int res = 0;
        while (x != 0) {
            if (res < Integer.MIN_VALUE / 10 || res > Integer.MAX_VALUE / 10) {
                return 0;
            }
            res = res * 10 + x % 10;
            x = x / 10;
        }
        return res;
    }
}
